package ar.edu.itba.pod.legajo45129.simul.market;

import com.google.common.base.Preconditions;

import ar.edu.itba.pod.legajo45129.simul.communication.ConnectionManagerImpl;
import ar.edu.itba.pod.simul.market.MarketInspector;
import ar.edu.itba.pod.simul.market.MarketManager;

public class MarketManagerImpl implements MarketManager {
	
	private MyMarket market;
	private ConnectionManagerImpl connectionManager;

	public MarketManagerImpl(ConnectionManagerImpl connectionManager) {
		this.connectionManager = connectionManager;
	}

	@Override
	public MarketInspector inspector() {
		return market();
	}

	@Override
	public MyMarket market() {
		Preconditions.checkNotNull(market);
		return market;
	}

	@Override
	public void shutdown() {
		market.finish();

	}

	@Override
	public void start() {
		market = new MyMarket(connectionManager);
		market.start();

	}

}
